package com.sixuerain.heartkey.app;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;

import com.sixuerain.heartkey.R;
import com.sixuerain.heartkey.data.LectionMgr;
import com.sixuerain.heartkey.data.LectionText;

public class LectionReaderActivity extends Activity {
	 public static final String LectionReader_ACTION = "com.sixuerain.HeartKey.LECTIONREADER";
	 private static TextView mLectionTitle;
	 private static TextView mLectionPronounce;
	 private static TextView mLectionContent;
	 
	 //data
	 private static LectionMgr mLectionMgr;
	 private String mlecTitle;
	 private LectionText mLectionText;
	 
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		
		Bundle extras = this.getIntent().getExtras();
		mlecTitle = extras.getString("lection_title");
		
		mLectionMgr = LectionListActivity.getLectionMgr();
		InitLectionReaderUI();
		
		
	}
	
	private void InitLectionReaderUI()
	{
		this.setContentView(R.layout.lection_reader);
		
		mLectionTitle = (TextView)findViewById(R.id.lection_text_title);
		mLectionPronounce = (TextView)findViewById(R.id.lection_text_pronounce);
		mLectionContent =(TextView)findViewById(R.id.lection_text_content);
		
		mLectionText = mLectionMgr.GetLectionbyTitle(mlecTitle);
		
		
		mLectionTitle.setText(mLectionText.Title);
		
		StringBuilder strBuilder = new StringBuilder();
//		for(String s:mLectionText.Pronouncearray)
//		{
//			strBuilder.append(s);
//		}
//		mLectionPronounce.setText(strBuilder);
		
		for(String s:mLectionText.Contentarray)
		{
			strBuilder.append(s);
		}
		mLectionContent.setText(strBuilder);

	}
	
	public  static Intent createNewIntent(String lecTitle) {
		Intent intent = new Intent(LectionReader_ACTION);
		Bundle bundle = new Bundle();
		bundle.putString("lection_title", lecTitle);
		intent.putExtras(bundle);
		
		return intent;
	}

}
